<!--
 * @Description: 
 * @Author: Chen bi
 * @Date: 2022-09-09 10:44:06
 * @LastEditTime: 2022-09-11 12:05:37
 * @LastEditors: Chen bi
-->

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        ul {
            width: 100vw;
            display: flex;
            justify-content: space-evenly;
            box-sizing: border-box;
            padding: 10px;
            list-style: none;
            background-color: aqua;
        }

        li {
            cursor: pointer;
            width: 100px;
            height: 100px;
            text-align: center;
            line-height: 100px;
        }

        .bg-red {
            background-color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="(v,index) in list" :key="index" @click="localClick = v" :class="{
                'bg-red':  v === localClick
            }">
                {{v}}
            </li>
        </ul>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                list: ["标题1", "标题2", "标题3", "标题4"],
                localClick: ''
            },
        })
    </script>
</body>

</html>